#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <getopt.h>

#include "fitsio.h"

#include "ccd290_config.h"

#include "dictionary.h"
#include "iniparser.h"

#include "misc.h"

#ifndef uint
    #define uint uint32_t 
#endif

#ifndef _CCD290_EXTRACT_H_
#define _CCD290_EXTRACT_H_

#define CH_NUM     16   // 通道数目

#define N_ROW_333K	1200
#define N_ROW_636K	2100	// 636K



void make_fake_ccd_data(char fname[], ccd290_config* cfg);

void get_rows_ob_tag( char in_file[], char out_file[], int line_start, int line_end, ccd290_config *cfg );
void get_rows_ob_tag_no_shift( char in_file[], char out_file[], int line_start, int line_end, ccd290_config *cfg );// no 4-bit shift caused by IDDR

void extract_ccd290_16ch(   char bin_file[], 
                            char fits_file[], 
                            char key_file[],
                            ccd290_config* cfg );

// when raw_dtype_is_float == 0, call extract_ccd290_16ch_uint16(****)
void extract_ccd290_16ch_uint16( char bin_file[], 
                                 char fits_file[], 
                                 char key_file[],
                                 ccd290_config* cfg );

// when raw_dtype_is_float == 1, call extract_ccd290_16ch_flt(****)
void extract_ccd290_16ch_flt(   char bin_file[], 
                                char fits_file[], 
                                char key_file[],
                                ccd290_config* cfg );


void extract_ccd290_16ch_csst(  char bin_file[], 
                                char fits_file[], 
                                char key_file[],
                                ccd290_config* cfg );


void add_fits_keywords_from_ini( fitsfile *fptr, char *inifile );

#endif
